package jvms.dynamicProxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * Created by pc on 2015/5/4.
 */
public class SpeakInvocationHandler implements InvocationHandler {
    public Object target;

    SpeakInvocationHandler(Object target) {
        this.target = target;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println(method.getName() + " invoked!");
        Object result = method.invoke(target, args);
        System.out.println(method.getName() + " return!");
        return result;
    }
}
